//
//  UIImage+Extesion.swift
//  Teamo
//
//  Created by mdzz on 2021/12/3.
//

import UIKit

extension UIImage {
    
    
    /// color 生成 image
    /// - Parameters:
    ///   - color: 颜色
    ///   - size: 大小
    /// - Returns: image
    public static func image(with color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage? {
        let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
        UIGraphicsBeginImageContext(rect.size)
        guard let context = UIGraphicsGetCurrentContext() else {
            return nil
        }
        context.setFillColor(color.cgColor)
        context.fill(rect)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return image
    }
}
